package com.fmi.timedealer.achievement;

import java.io.Serializable;

import com.fmi.timedealer.ActivityItem;

public class AchievementLevelItem implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 9186589717396352501L;
	private ActivityItem activityItem;
	private int goalTrackTime;
	private int remainingTime;
	public int getRemainingTime() {
		return remainingTime;
	}

	public void setRemainingTime(int remainingTime) {
		this.remainingTime = remainingTime;
	}

	private int id;
	private boolean isCompleted;

	public AchievementLevelItem(int id, ActivityItem item, int goal, int remaining, boolean isCompleted) {
		this.activityItem = item;
		this.goalTrackTime = goal;
		this.remainingTime = remaining;
		this.id = id;
		this.isCompleted = isCompleted;
	}
	
	public AchievementLevelItem(ActivityItem item, int goal, boolean isCompleted) {
		this(0, item, goal, 0, isCompleted);
	}
	
	public AchievementLevelItem() {
		this(0, new ActivityItem("", "", ""), 10, 0, false);
	}
	
	public ActivityItem getActivityItem() {
		return activityItem;
	}
	public void setActivityItem(ActivityItem activityItem) {
		this.activityItem = activityItem;
	}
	public int getGoalTrackTime() {
		return goalTrackTime;
	}
	public void setGoalTrackTime(int goalTrackTime) {
		this.goalTrackTime = goalTrackTime;
	}

	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
	
	public boolean isCompleted() {
		return isCompleted;
	}

	public void setCompleted(boolean isCompleted) {
		this.isCompleted = isCompleted;
	}
	
	public void updateRemaining(int spentTime) {
		this.remainingTime = this.goalTrackTime - spentTime/60;
		if (this.remainingTime <= 0) {
			this.remainingTime = 0;
			this.isCompleted = true;
		} else {
			this.isCompleted = false;
		}
	}
}
